//
//  NEDTextInputNumber.m
//  AddressBookCloud
//
//  Created by 林宁宁 on 2020/5/11.
//  Copyright © 2020 林宁宁. All rights reserved.
//

#import "NEDTextInputNumber.h"

@interface NEDTextInputNumber()

@property (assign, nonatomic) NSInteger maxCount;
@property (assign, nonatomic) NSInteger decimalCount;
@property (assign, nonatomic) NSInteger limitCount;

@end

@implementation NEDTextInputNumber

-(instancetype)initWithMaxCount:(NSInteger)maxCount{
    self = [super init];
    if(self){
        self.maxCount = maxCount;
    }
    return self;
}
-(instancetype)initWithLimitCount:(NSInteger)limitCount{
    self = [super init];
    if(self){
        self.limitCount = limitCount;
    }
    return self;
}
-(instancetype)initWithMaxCount:(NSInteger)maxCount decimal:(NSInteger)decimalCount{
    self = [super init];
    if(self){
        self.maxCount = maxCount;
        self.decimalCount = decimalCount;
    }
    return self;
}

-(NSInteger)formatMaxTextLength{
    if(self.maxCount > 0){
        return self.maxCount;
    }
    return FLT_MAX;
}

- (NSInteger)formatDecimalLength{
    if(self.decimalCount > 0){
        return self.decimalCount;
    }
    return FLT_MAX;
}

-(NSInteger)formatLimitLength{
    if(self.limitCount > 0){
        return self.limitCount;
    }
    return 0;
}

-(UIKeyboardType)formatKeyBoardType{
    return UIKeyboardTypeDecimalPad;
}

-(NSString *)formatInputLimitChar{
    return @"0123456789.";
}

@end
